import Cpp.Request 1.0 as Request
import Cpp.Type 1.0

import "../Base/Utils"
import "../Base/Code" as Code

UserInfoForm {
    id:root
    signal ok
    signal back
    changeHeadImageButton.onClicked: {
        picker.open()
    }
    backButton.onClicked: {
        root.back()
    }
    okButton.onClicked: {
        userInfoRequest.change(headImage.source, nicknameInput.text)
    }

    uploadMask.visible: uploader.status === Code.RequestCode.communicating
    uploadMask.progress: uploader.progress

    okButton.visible: uploader.status === Code.RequestCode.ok && nicknameInput.acceptableInput

    ImagePicker {
        id:picker
        onAccepted: {
            uploader.upload(fileUrl)
            headImage.source = fileUrl
        }
    }

    Request.FileUploader {
        id:uploader
        onOk: {
            headImage.source = uploader.remoteUrl
            console.log("ok, current source url : ", headImage.source)
        }
    }

    Request.UserInfo {
        id:userInfoRequest
        onOk: {
//            root.ok()
        }
    }
}
